Component({
    properties: {
        value: {
            type: Array,
            value: [],
            observer: "onValue"
        },
        isShow: {
            type: Boolean,
            value: !1,
            observer: "onShow"
        }
    },
    data: {
        years: [],
        months: [],
        days: [],
        tempYearPos: [ 0 ],
        tempMonthPos: [ 0 ],
        tempDayPos: [ 0 ],
        showPicker: !1
    },
    attached: function() {
        for (var t, a = new Date(), e = [], s = [], h = 1900; h <= a.getFullYear(); h++) e.push(h);
        for (var o = 1; o <= 12; o++) {
            var n;
            n = o < 10 ? "0" + o : o, s.push(n);
        }
        t = this.getDays(a.getFullYear(), a.getMonth() + 1), this.setData({
            years: e,
            months: s,
            days: t
        });
    },
    methods: {
        onTouchmask: function(t) {},
        onCacnelClick: function(t) {
            this.triggerEvent("cancelclick", {});
        },
        onSureClick: function(t) {
            var a = [ this.data.years[this.data.tempYearPos], this.data.months[this.data.tempMonthPos], this.data.days[this.data.tempDayPos] ];
            this.triggerEvent("sureclick", {
                value: a
            });
        },
        year_onChange: function(t) {
            var a, e = this.data.years[t.detail.value];
            a = this.getDays(e, 1), this.setData({
                days: a,
                tempYearPos: t.detail.value,
                tempMonthPos: [ 0 ],
                tempDayPos: [ 0 ]
            });
        },
        month_onChange: function(t) {
            var a, e = this.data.years[this.data.tempYearPos], s = this.data.months[t.detail.value];
            a = this.getDays(e, s), this.setData({
                days: a,
                tempMonthPos: t.detail.value,
                tempDayPos: [ 0 ]
            });
        },
        day_onChange: function(t) {
            this.setData({
                tempDayPos: t.detail.value
            });
        },
        onValue: function() {
            var t = this.getRefreshData();
            this.setData(t);
        },
        onShow: function() {
            var t = this.getRefreshData();
            t.showPicker = this.data.isShow, this.setData(t);
        },
        getDays: function(t, a) {
            var e = [];
            a = parseInt(a, 10);
            for (var s = new Date(t, a, 0).getDate(), h = 1; h <= s; h++) {
                var o;
                o = h < 10 ? "0" + h : h, e.push(o);
            }
            return e;
        },
        getRefreshData: function() {
            if (null == this.data.years || 0 == this.data.years.length) return {};
            for (var t = new Date(), a = this.data.years.length - 1, e = t.getMonth(), s = t.getDate() - 1, h = 0; h < this.data.years.length; h++) {
                if (this.data.years[h] == this.data.value[0]) {
                    a = h;
                    break;
                }
            }
            for (h = 0; h < this.data.months.length; h++) {
                if (this.data.months[h] == this.data.value[1]) {
                    e = h;
                    break;
                }
            }
            var o, n = this.data.years[a];
            o = this.getDays(n, this.data.months[e]);
            for (h = 0; h < o.length; h++) {
                if (o[h] == this.data.value[2]) {
                    s = h;
                    break;
                }
            }
            return {
                days: o,
                tempYearPos: [ a ],
                tempMonthPos: [ e ],
                tempDayPos: [ s ]
            };
        }
    }
});